package com.atguigu.memento.theory;

public class Client {
	public static void main(String[] args) {
		Originator originator = new Originator();
		Caretaker caretaker = new Caretaker();
		
		originator.setState("状态1");
		
		//保存了当前的状态
		caretaker.add(originator.saveStateMemento());
		
		originator.setState("状态2");
		
		caretaker.add(originator.saveStateMemento());
		
		originator.setState("状态3");
		
		caretaker.add(originator.saveStateMemento());
		
		//希望恢复到状态1
		System.out.println("当前状态是=" + originator.getState());
		
		originator.getStateFromMemento(caretaker.get(0));
		
		System.out.println("恢复到状态1=" + originator.getState());
		
	}
}
